<?php
/**
 * Created by PhpStorm.
 * User: jz
 * Date: 16/7/7
 * Time: 上午11:47
 */
function do_html_header($title)
{
?>
<html>
<head>
        <meta charset="utf-8">
        <title><?php echo $title;?></title>
        <style>
                body{
                        font-family:Arial, Helvetica, sans-serif;
                        font-size:13px;
                }
                li,td{
                        font-family:Arial, Helvetica, sans-serif;
                        font-size:13px;
                }
        </style>
</head>
<body>
<img src="bookmark.jpg" alt="PHPbookmark.logo" border="0" align="left" valign="bottom" height="55", width="57">
<h1>PHPbookmark</h1>
<hr/>
<?php 
        if($title){
                do_html_heading($title);
        }
    
}

function do_html_footer()
{
?>
        </body>
        </html>
<?php
}
function do_html_heading($title)
{
        echo "<h2>$title</h2>";
}
function display_site_info()
{
?>
    <ul>
            <li>在线保存您的书签</li>
            <li>查看其他人都用了哪些功能</li>
            <li>分享你最感兴趣的链接</li>
    </ul>
<?php        
}
?>

<?php
function display_register_form()
{
        ?>


        <form action="register_new.php" method="post">
                <table>
                        <tr>
                                <td>邮箱:</td>
                                <td><input type="email" name="regi_email" size="30" maxlength="100"></td>
                        </tr>
                        <tr>
                                <td>用户名:<br>最大16位</td>
                                <td><input type="text" name="username" size="16" maxlength="16"></td>
                        </tr>
                        <tr>
                                <td>密码:</td>
                                <td><input type="password" name="password" size="16" maxlength="16"></td>
                        </tr>
                        <tr>
                                <td>密码确认:</td>
                                <td><input type="password" name="confirm_pass" size="16" maxlength="16"></td>
                        </tr>
                        <tr>
                                <td align="center" colspan="2"><button type="submit">注册</button></td>
                        </tr>
                </table>
        </form>
        <?php
}
function display_login_form()
{
?>
        <a href="register_form.php">注册</a>
        <form action="member.php" method="post">
                <table>
                        <caption>请在此登陆</caption>
                        <tr>
                                <td>用户名:</td>
                                <td><input type="text" name="username" placeholder="用户名"></td>
                        </tr>
                        <tr>
                                <td>密码:</td>
                                <td><input type="password" name="password" placeholder="密码"></td>
                        </tr>
                        <tr>
                                <td align="center" colspan="2"><button type="submit">登陆</button></td>
                        </tr>
                        <tr><td colspan="2"><a href="forgot_form.php">忘记密码?</a></td></tr>
                </table>
        </form>
<?php
}
function do_html_url($url, $name)
{
    echo "<br /><a href=\"$url\">$name</a><br/>";
}
function display_user_urls($url_array) 
{
        // display the table of URLs

        // set global variable, so we can test later if this is on the page
  global $bm_table;
  $bm_table = true;
?>
        <br />
        <form name="bm_table" action="delete_bms.php" method="post">
                <table width="300" cellpadding="2" cellspacing="0">
                        <?php
                        $color = "#cccccc";
                        echo "<tr bgcolor=\"".$color."\"><td><strong>Bookmark</strong></td>";
                        echo "<td><strong>Delete?</strong></td></tr>";
                        if ((is_array($url_array)) && (count($url_array) > 0)) {
                                foreach ($url_array as $url)  {
                                        if ($color == "#cccccc") {
                                                $color = "#ffffff";
                                        } else {
                                                $color = "#cccccc";
                                        }
                                        //remember to call htmlspecialchars() when we are displaying user data
                                        echo "<tr bgcolor=\"".$color."\"><td><a href=\"".$url."\">".htmlspecialchars($url)."</a></td>
            <td><input type=\"checkbox\" name=\"del_me[]\"
                value=\"".$url."\"/></td>
            </tr>";
                                }
                        } else {
                                echo "<tr><td>No bookmarks on record</td></tr>";
                        }
                        ?>
                </table>
        </form>
<?php
}
function display_user_menu()
{
?>
    <hr/>
    <a href="member.php">主页</a>&nbsp;|&nbsp;
    <a href="add_bm_form.php">添加标签</a>&nbsp;|&nbsp;
    <?php
        global $bm_table;
        if ($bm_table){
            echo "<a href=\"#\" onclick=\"bm_table.submit();\">删除标签</a>&nbsp;|&nbsp;";
        }else {
            echo "<span href=\"#\">删除标签</span>&nbsp;|&nbsp;";
        }
    ?>
    <a href="change_password_form.php">修改密码</a><br/>
    <a href="recommend.php">推荐给我</a>&nbsp;|&nbsp;
    <a href="logout.php">登出</a>
    <hr/>
    
<?php
}

function display_recommend_urls($urls)
{
    echo '<table>';
    echo '<tr><td bgcolor=\"#a9a9a9\">推荐标签</td></tr>';
    foreach($urls as $key => $url){
        $url = htmlspecialchars($url);
        echo "<tr><td >$url</td></tr>";
    }
    echo '</table>';
}

?>




